package com.example.hotel.service.impl;

import com.example.hotel.dao.DayRoomInfoDao;
import com.example.hotel.entity.DayRoomInfo;
import com.example.hotel.service.DayRoomInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (DayRoomInfo)表服务实现类
 */
@Service("dayRoomInfoService")
public class DayRoomInfoServiceImpl implements DayRoomInfoService {
    @Resource
    private DayRoomInfoDao dayRoomInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public DayRoomInfo queryById(Integer id) {
        return this.dayRoomInfoDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<DayRoomInfo> queryAllByLimit(int offset, int limit) {
        return this.dayRoomInfoDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param dayRoomInfo 实例对象
     * @return 实例对象
     */
    @Override
    public DayRoomInfo insert(DayRoomInfo dayRoomInfo) {
        this.dayRoomInfoDao.insert(dayRoomInfo);
        return dayRoomInfo;
    }

    /**
     * 修改数据
     *
     * @param dayRoomInfo 实例对象
     * @return 实例对象
     */
    @Override
    public DayRoomInfo update(DayRoomInfo dayRoomInfo) {
        this.dayRoomInfoDao.update(dayRoomInfo);
        return this.queryById(dayRoomInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.dayRoomInfoDao.deleteById(id) > 0;
    }

    /**
     * 查询所有数据
     */
    public List<DayRoomInfo> queryAll(DayRoomInfo dayRoomInfo) {
        return this.dayRoomInfoDao.queryAll(dayRoomInfo);
    }

    /**
     * 通过指定字段查询单条数据
     */
    @Override
    public DayRoomInfo queryByName(DayRoomInfo dayRoomInfo) {
        return this.dayRoomInfoDao.queryByName(dayRoomInfo);
    }

}